package com.qc.bug.Services.Impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qc.bug.Dao.UserInfoMapper;
import com.qc.bug.Services.userInfoServices;
import com.qc.bug.Util.MD5;
import com.qc.bug.pojo.UserInfo;

@Service
public class userInfoServicesImpl implements userInfoServices{

	@Autowired
	private UserInfoMapper userInfoMap;
	
	/**
	 * 用户登录
	 */
	public UserInfo userLogin(String phone, String pwd) {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("phone", phone);
		map.put("pwd", MD5.getMd5(pwd));
		
		
		return userInfoMap.userLogin(map);
	}

	public int updateLastLoginTime(UserInfo userinfo) {
		
		
		return userInfoMap.updateLoginTime(userinfo);
	}

	/**
	 * 注册用户
	 */
	public int userRegister(UserInfo userinfo) {

		userinfo.setPassword(MD5.getMd5(userinfo.getPassword()));
		return userInfoMap.userRegister(userinfo);
	}

	/**
	 * 设置注册时间
	 */
	public int setRegistrTime(UserInfo userinfo) {
		
		return  userInfoMap.setRegistrTime(userinfo);
	}

	/**
	 * 修改密码
	 */
	public int updatePwd(String phone, String password) {
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("phone", phone);
		map.put("password", MD5.getMd5(password));

		return userInfoMap.updatePwd(map);
	}

	public int updateUserMail(UserInfo userinfo) {
		
		return userInfoMap.updateUserMail(userinfo);
	}
	
	
}
